import Vue from 'vue'
import VueRouter from "vue-router"
import FrontPage from "./views/FrontPage"
import PcIndex from "./views/PcIndex"
import MoveIndex from "./move/MoveIndex"
import MoveTalk from "./move/MoveTalk"
import App from "./App"


Vue.use(VueRouter)


//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}




// const routes = [
//     {
//     path: '/',
//     redirect:redirectPath
//     }]
const routes = [

    //pc端路由配置
    {
        path: "/",
        component: App,
    },
    {
        path: "/PcIndex",
        name: "PcIndex",
        component: PcIndex,
        children: [
            {
                path: "/PcIndex/FrontPage",
                name: "FrontPage",
                component: FrontPage,

            },
            {
                path: "/PcIndex/AboutAutor",
                component: () => import('./views/AboutAutor'),

            },
            {
                path: "/PcIndex/Topic",
                component: () => import('./views/Topic')
            },
            {
                path: "/PcIndex/Archive",
                name: "Archive",
                component: () => import('./views/Archive')
            },
            {
                path: "/PcIndex/FriendLink",
                component: () => import('./views/FriendLink')
            },

            {
                path: "/PcIndex/Write",
                component: () => import('./views/Write'),
            },
            {
                path: "/PcIndex/Write2",
                component: () => import('./views/Write2'),
            },

        ]

    },


    //移动端路由配置
    {
        path: "/MoveIndex",
        name: "MoveIndex",
        component: MoveIndex,
        redirect: "/MoveIndex/MoveTalk",
        children: [
            {
                path: "/MoveIndex/MoveTalk",
                name: "MoveTalk",
                component: MoveTalk
            },
            {
                path: "/MoveIndex/MovePublish",
                name: "MovePublish",
                component: () => import('./move/MovePublish'),


            },
            {
                path: "/MoveIndex/MoveAbout",
                component: () => import('./move/MoveAbout'),

            },
            {
                path: "/MoveIndex/MoveTopic",
                component: () => import('./move/MoveTopic')
            },
            {
                path: "/MoveIndex/MoveArchive",
                component: () => import('./move/MoveArchive')
            },
        ]

    },


]

export default new VueRouter({
    routes,
    mode: 'history',
    scrollBehavior(to, from, savedPosition) {
        return { x: 0, y: 0 }
    }
})